<?php

/**
 * uniBoard API abstraction
 *
 * Light and fast forum solution for web 2.0-like communities.
 *
 * @package		uniBoard
 * @author		Rafał Pitoń
 * @license		http://www.gnu.org/licenses/gpl-3.0.html
 * @since		Version 0.1
 * 
 * ------------------------------------------------------------------------
 * 
 * $Date: 2010-09-20 21:23:27 +0000 (Mon, 20 Sep 2010) $
 * $Revision: 64 $
 * $Author: rafio.xudb@gmail.com $
 */

// ------------------------------------------------------------------------

abstract class class_api{
	
	/**
	 * Got error while doing action?
	 *
	 * @var bool
	 */
	
	public $error 			= false;
		
	/**
	 * Last error message
	 *
	 * @var string
	 */
	
	public $last_error		= '';
		
	/**
	 * data loaded?
	 *
	 * @var bool
	 */
	
	public $data_loaded		= false;
		
	/**
	 * Error message
	 *
	 * @var array
	 */
	
	public $errors			= array();
	
	/**
	 * Changes history
	 *
	 * @var array
	 */
	
	private $changes 		= array();
	
	// ------------------------------------------------------------------------
	
	/**
	 * Adds error to api
	 *
	 * @param string $error_message
	 * @param string $error_code
	 */
	
	function setError( $error_message = '', $error_code = ''){
		
		// Tell api we have error
		$this -> error = true;
		
		// Set last error message
		$this -> last_error = $error_message;
		
		// Set error code?
		if ( !empty( $error_code))
		{
			// Put error message under code id
			$this -> errors[$error_code] = $error_message;
		}
		else
		{
			// Simply put error message to list
			$this -> errors[] = $error_message;
		}
		
	}
	
}